home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / term-source.lha / termVerify.c < prev    next >
C/C++ Source or Header  |  1995-06-17  |  14KB  |  784 lines

  1. /*
  2. **    termVerify.c
  3. **
  4. **    Check if files/drawers/programs are where they should be
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14. struct Path
  15. {
  16.     BPTR    path_Next,
  17.             path_Lock;
  18. };
  19.  
  20.     /* FindPath(struct Window *Parent,STRPTR Path,BOOLEAN CanCreate,LONG *Error):
  21.      *
  22.      *    For the complete path of a file, this checks if the
  23.      *    path leading to the file actually exists. This is
  24.      *    primarily for files the program should create. Thus,
  25.      *    the file in question may not yet exist.
  26.      */
  27.  
  28. BOOLEAN __regargs
  29. FindPath(struct Window *Parent,STRPTR Path,BOOLEAN CanCreate,LONG *Error)
  30. {
  31.     UBYTE    LocalBuffer[MAX_FILENAME_LENGTH];
  32.     STRPTR    Index;
  33.  
  34.     strcpy(LocalBuffer,Path);
  35.  
  36.     Index = PathPart(LocalBuffer);
  37.  
  38.     *Index = 0;
  39.  
  40.     return(FindDrawer(Parent,LocalBuffer,CanCreate,Error));
  41. }
  42.  
  43.     /* FindDrawer(struct Window *Parent,STRPTR Drawer,BOOLEAN CanCreate,LONG *Error):
  44.      *
  45.      *    Check if a given drawer exists and give
  46.      *    the user the choice to create it if necessary.
  47.      */
  48.  
  49. BOOLEAN __regargs
  50. FindDrawer(struct Window *Parent,STRPTR Drawer,BOOLEAN CanCreate,LONG *Error)
  51. {
  52.     APTR    OldPtr = ThisProcess -> pr_WindowPtr;
  53.     BPTR    FileLock;
  54.     BOOLEAN    Result = FALSE;
  55.     LONG    LocalError;
  56.  
  57.     if(!Config -> MiscConfig -> ProtectiveMode)
  58.         return(TRUE);
  59.  
  60.     if(!Error)
  61.         Error = &LocalError;
  62.  
  63.         // Lock out DOS requesters
  64.  
  65.     ThisProcess -> pr_WindowPtr = (APTR)-1;
  66.  
  67.         // Does the drawer exist?
  68.  
  69.     if(FileLock = Lock(Drawer,ACCESS_READ))
  70.     {
  71.         struct FileInfoBlock __aligned FileInfo;
  72.  
  73.             // Take a closer look
  74.  
  75.         if(Examine(FileLock,&FileInfo))
  76.         {
  77.                 // Is this actually a file?
  78.  
  79.             if(FileInfo . fib_DirEntryType < 0)
  80.                 *Error = ERR_NOT_A_DRAWER;
  81.             else
  82.             {
  83.                 *Error = 0;
  84.  
  85.                 Result = TRUE;
  86.             }
  87.         }
  88.         else
  89.             *Error = IoErr();
  90.  
  91.         UnLock(FileLock);
  92.     }
  93.     else
  94.     {
  95.         LONG Result2 = IoErr();
  96.  
  97.             // If it doesn't exist, see if we should ask the user to create it
  98.  
  99.         if(Result2 == ERROR_OBJECT_NOT_FOUND && Parent && CanCreate)
  100.         {
  101.             UBYTE    LocalBuffer[MAX_FILENAME_LENGTH];
  102.             STRPTR    Index;
  103.             BOOLEAN    CanCreate = FALSE;
  104.  
  105.                 // Chop off the last path part
  106.  
  107.             strcpy(LocalBuffer,Drawer);
  108.  
  109.             Index = PathPart(LocalBuffer);
  110.  
  111.             *Index = 0;
  112.  
  113.                 // Get a lock on the parent drawer
  114.  
  115.             if(FileLock = Lock(LocalBuffer,ACCESS_READ))
  116.             {
  117.                 struct InfoData __aligned InfoData;
  118.  
  119.                     // Inquire volume information
  120.  
  121.                 if(Info(FileLock,&InfoData))
  122.                 {
  123.                         // Can we write to this volume?
  124.  
  125.                     if(InfoData . id_DiskState == ID_VALIDATED)
  126.                         CanCreate = TRUE;
  127.                 }
  128.  
  129.                 UnLock(FileLock);
  130.             }
  131.  
  132.                 // Give it a try?
  133.  
  134.             if(CanCreate)
  135.             {
  136.                 LT_LockWindow(Parent);
  137.  
  138.                     // Ask if we should create it
  139.  
  140.                 if(MyEasyRequest(Parent,LocaleString(MSG_VERIFY_NO_DRAWER_TXT),LocaleString(MSG_GLOBAL_YES_NO_TXT),Drawer))
  141.                 {
  142.                     if(FileLock = CreateDir(Drawer))
  143.                     {
  144.                         Result2 = 0;
  145.  
  146.                         Result = TRUE;
  147.  
  148.                         UnLock(FileLock);
  149.                     }
  150.                     else
  151.                         Result2 = IoErr();
  152.                 }
  153.                 else
  154.                 {
  155.                     Result2 = 0;
  156.                     Result = TRUE;
  157.                 }
  158.  
  159.                 LT_UnlockWindow(Parent);
  160.             }
  161.         }
  162.  
  163.         *Error = Result2;
  164.     }
  165.  
  166.     ThisProcess -> pr_WindowPtr = OldPtr;
  167.  
  168.     if(Window && !Result && *Error)
  169.     {
  170.         LT_LockWindow(Parent);
  171.  
  172.         if(*Error == ERR_NOT_A_DRAWER)
  173.             ShowError(Parent,*Error,NULL,Drawer);
  174.         else
  175.             ShowError(Parent,ERR_DRAWER_NOT_FOUND,*Error,Drawer);
  176.  
  177.         LT_UnlockWindow(Parent);
  178.     }
  179.  
  180.     return(Result);
  181. }
  182.  
  183.     /* FindFile(struct Window *Parent,STRPTR File,LONG *Error):
  184.      *
  185.      *    Try to locate a file.
  186.      */
  187.  
  188. BOOLEAN __regargs
  189. FindFile(struct Window *Parent,STRPTR File,LONG *Error)
  190. {
  191.     APTR    OldPtr = ThisProcess -> pr_WindowPtr;
  192.     BPTR    FileLock;
  193.     BOOLEAN    Result = FALSE;
  194.     LONG    LocalError;
  195.  
  196.     if(!Config -> MiscConfig -> ProtectiveMode)
  197.         return(TRUE);
  198.  
  199.     if(!Error)
  200.         Error = &LocalError;
  201.  
  202.         // Lock out DOS requesters
  203.  
  204.     ThisProcess -> pr_WindowPtr = (APTR)-1;
  205.  
  206.         // Try to get a lock on the file
  207.  
  208.     if(FileLock = Lock(File,ACCESS_READ))
  209.     {
  210.         struct FileInfoBlock __aligned FileInfo;
  211.  
  212.             // Take a closer look
  213.  
  214.         if(Examine(FileLock,&FileInfo))
  215.         {
  216.                 // Is it actually a drawer?
  217.  
  218.             if(FileInfo . fib_DirEntryType > 0)
  219.                 *Error = ERR_NOT_A_FILE;
  220.             else
  221.             {
  222.                 *Error = 0;
  223.  
  224.                 Result = TRUE;
  225.             }
  226.         }
  227.         else
  228.             *Error = IoErr();
  229.  
  230.         UnLock(FileLock);
  231.     }
  232.     else
  233.         *Error = IoErr();
  234.  
  235.     ThisProcess -> pr_WindowPtr = OldPtr;
  236.  
  237.     if(Window && !Result && *Error)
  238.     {
  239.         LT_LockWindow(Parent);
  240.  
  241.         if(*Error == ERR_NOT_A_FILE)
  242.             ShowError(Parent,*Error,NULL,File);
  243.         else
  244.             ShowError(Parent,ERR_FILE_NOT_FOUND,*Error,File);
  245.  
  246.         LT_UnlockWindow(Parent);
  247.     }
  248.  
  249.     return(Result);
  250. }
  251.  
  252.     /* FindARexxComment(STRPTR LocalBuffer,LONG Len):
  253.      *
  254.      *    Check for a valid ARexx file comment.
  255.      */
  256.  
  257. STATIC BOOLEAN __regargs
  258. FindARexxComment(STRPTR LocalBuffer,LONG Len)
  259. {
  260.     register WORD    i;
  261.     register UBYTE    c;
  262.  
  263.     for(i = 0 ; i < Len - 1 ; i++)
  264.     {
  265.         c = LocalBuffer[i];
  266.  
  267.             // Stop on invalid characters.
  268.  
  269.         if((c < ' ' && c != '\r' && c != '\n' && c != '\a') || (c >= 127 && c < 160))
  270.             break;
  271.         else
  272.         {
  273.                 // Looks like the typical
  274.                 // introductory comment line.
  275.  
  276.             if(c == '/' && LocalBuffer[i + 1] == '*')
  277.                 return(TRUE);
  278.         }
  279.     }
  280.  
  281.     return(FALSE);
  282. }
  283.  
  284.     /* FindProgram(struct Window *Parent,STRPTR Program,LONG *Error):
  285.      *
  286.      *    Try to find a program given by name. Firstly, try to access the
  287.      *    file by its name. If unsuccessful, search the Shell path list.
  288.      *    As a last resort, search the global AmigaDOS resident program
  289.      *    list. Note that while this routine may fail program execution
  290.      *    may still work. WShell for example maintains its own internal
  291.      *    resident list.
  292.      */
  293.  
  294. BOOLEAN __regargs
  295. FindProgram(struct Window *Parent,STRPTR Program,LONG *Error)
  296. {
  297.     UBYTE    LocalBuffer[MAX_FILENAME_LENGTH];
  298.     APTR    OldPtr = ThisProcess -> pr_WindowPtr;
  299.     BPTR    FileLock;
  300.     WORD    i;
  301.     BOOLEAN    Result        = FALSE,
  302.             CanExecute    = FALSE;
  303.     LONG    LocalError;
  304.  
  305.     if(!Config -> MiscConfig -> ProtectiveMode)
  306.         return(TRUE);
  307.  
  308.     if(!Error)
  309.         Error = &LocalError;
  310.  
  311.         // Chop off the program arguments
  312.  
  313.     strcpy(LocalBuffer,Program);
  314.  
  315.     for(i = 0 ; i < strlen(LocalBuffer) ; i++)
  316.     {
  317.         if(LocalBuffer[i] == ' ')
  318.         {
  319.             LocalBuffer[i] = 0;
  320.  
  321.             break;
  322.         }
  323.     }
  324.  
  325.     Program = LocalBuffer;
  326.  
  327.         // Lock out DOS requesters
  328.  
  329.     ThisProcess -> pr_WindowPtr = (APTR)-1;
  330.  
  331.         // Try to lock the program
  332.  
  333.     if(FileLock = Lock(Program,ACCESS_READ))
  334.     {
  335.         struct FileInfoBlock __aligned FileInfo;
  336.  
  337.             // Take a closer look
  338.  
  339.         if(Examine(FileLock,&FileInfo))
  340.         {
  341.                 // Is it actually a drawer?
  342.  
  343.             if(FileInfo . fib_DirEntryType > 0)
  344.                 *Error = ERR_NOT_A_FILE;
  345.             else
  346.             {
  347.                     // So far, so good
  348.  
  349.                 *Error = 0;
  350.  
  351.                 Result = TRUE;
  352.  
  353.                     // Is it marked as being executable?
  354.  
  355.                 if(!(FileInfo . fib_Protection & FIBF_EXECUTE))
  356.                 {
  357.                     BPTR    FileHandle;
  358.                     ULONG    Value;
  359.  
  360.                         // Look at the contents
  361.  
  362.                     if(FileHandle = Open(Program,MODE_OLDFILE))
  363.                     {
  364.                         if(Read(FileHandle,&Value,sizeof(ULONG)) == sizeof(ULONG))
  365.                         {
  366.                                 // Not a failproof check, but better than nothing
  367.  
  368.                             if(Value == HUNK_HEADER)
  369.                                 CanExecute = TRUE;
  370.                         }
  371.  
  372.                         Close(FileHandle);
  373.                     }
  374.                 }
  375.                 else
  376.                 {
  377.                         // Does it have the script bit set? */
  378.  
  379.                     if(FileInfo . fib_Protection & FIBF_SCRIPT)
  380.                         CanExecute = TRUE;
  381.                     else
  382.                     {
  383.                         BPTR FileHandle;
  384.  
  385.                             // Now check if it's an ARexx script.
  386.  
  387.                         if(FileHandle = Open(Program,MODE_OLDFILE))
  388.                         {
  389.                             UBYTE    LocalBuffer[256];
  390.                             LONG    Len;
  391.  
  392.                             if((Len = Read(FileHandle,LocalBuffer,256)) > 0)
  393.                             {
  394.                                 if(CanExecute = FindARexxComment(LocalBuffer,Len))
  395.                                     Result = TRUE;
  396.                             }
  397.  
  398.                             Close(FileHandle);
  399.                         }
  400.                     }
  401.                 }
  402.             }
  403.         }
  404.  
  405.         UnLock(FileLock);
  406.     }
  407.     else
  408.     {
  409.         LONG Result2 = IoErr();
  410.  
  411.         if(Result2 == ERROR_DEVICE_NOT_MOUNTED)
  412.             *Error = ERROR_OBJECT_NOT_FOUND;
  413.         else
  414.             *Error = Result2;
  415.     }
  416.  
  417.         // Give it another try
  418.  
  419.     if(!Result || !CanExecute)
  420.     {
  421.             // Take care
  422.  
  423.         if(ThisProcess -> pr_CLI)
  424.         {
  425.             struct CommandLineInterface    *CLI = BADDR(ThisProcess -> pr_CLI);
  426.             BPTR                         StartCD,
  427.                                          Drawer;
  428.             struct Path                    *Path;
  429.             BOOLEAN                         InitialCD    = TRUE,
  430.                                          GotIt        = FALSE;
  431.  
  432.                 // Run down the Shell path search list
  433.  
  434.             for(Path = BADDR(CLI -> cli_CommandDir) ; Path && !GotIt ; Path = BADDR(Path -> path_Next))
  435.             {
  436.                 Drawer = CurrentDir(Path -> path_Lock);
  437.  
  438.                 if(InitialCD)
  439.                 {
  440.                     StartCD        = Drawer;
  441.                     InitialCD    = FALSE;
  442.                 }
  443.  
  444.                     // Try to lock the program
  445.  
  446.                 if(FileLock = Lock(Program,ACCESS_READ))
  447.                 {
  448.                     struct FileInfoBlock __aligned FileInfo;
  449.  
  450.                         // Take a closer look
  451.  
  452.                     if(Examine(FileLock,&FileInfo))
  453.                     {
  454.                             // Is this a file marked as being executable?
  455.  
  456.                         if(FileInfo . fib_DirEntryType < 0)
  457.                         {
  458.                             if(!(FileInfo . fib_Protection & FIBF_EXECUTE))
  459.                             {
  460.                                 BPTR    FileHandle;
  461.                                 ULONG    Value;
  462.  
  463.                                     // Look at the contents
  464.  
  465.                                 if(FileHandle = Open(Program,MODE_OLDFILE))
  466.                                 {
  467.                                     if(Read(FileHandle,&Value,sizeof(ULONG)) == sizeof(ULONG))
  468.                                     {
  469.                                             // Not a failproof check, but better than nothing
  470.  
  471.                                         if(Value == HUNK_HEADER)
  472.                                             GotIt = TRUE;
  473.                                     }
  474.  
  475.                                     Close(FileHandle);
  476.                                 }
  477.                             }
  478.                             else
  479.                             {
  480.                                     // Does it look like a script?
  481.  
  482.                                 if(FileInfo . fib_Protection & FIBF_SCRIPT)
  483.                                     GotIt = TRUE;
  484.                             }
  485.                         }
  486.                     }
  487.  
  488.                     UnLock(FileLock);
  489.                 }
  490.             }
  491.  
  492.             if(!GotIt)
  493.             {
  494.                 BPTR CommandDir = Lock("C:",ACCESS_READ);
  495.  
  496.                 Drawer = CurrentDir(CommandDir);
  497.  
  498.                 if(InitialCD)
  499.                 {
  500.                     StartCD        = Drawer;
  501.                     InitialCD    = FALSE;
  502.                 }
  503.  
  504.                     // Try to lock the program
  505.  
  506.                 if(FileLock = Lock(Program,ACCESS_READ))
  507.                 {
  508.                     struct FileInfoBlock __aligned FileInfo;
  509.  
  510.                         // Take a closer look
  511.  
  512.                     if(Examine(FileLock,&FileInfo))
  513.                     {
  514.                             // Is this a file marked as being executable?
  515.  
  516.                         if(FileInfo . fib_DirEntryType < 0)
  517.                         {
  518.                             if(!(FileInfo . fib_Protection & FIBF_EXECUTE))
  519.                             {
  520.                                 BPTR    FileHandle;
  521.                                 ULONG    Value;
  522.  
  523.                                     // Look at the contents
  524.  
  525.                                 if(FileHandle = Open(Program,MODE_OLDFILE))
  526.                                 {
  527.                                     if(Read(FileHandle,&Value,sizeof(ULONG)) == sizeof(ULONG))
  528.                                     {
  529.                                             // Not a failproof check, but better than nothing
  530.  
  531.                                         if(Value == HUNK_HEADER)
  532.                                             GotIt = TRUE;
  533.                                     }
  534.  
  535.                                     Close(FileHandle);
  536.                                 }
  537.                             }
  538.                             else
  539.                             {
  540.                                     // Does it look like a script?
  541.  
  542.                                 if(FileInfo . fib_Protection & FIBF_SCRIPT)
  543.                                     GotIt = TRUE;
  544.                             }
  545.                         }
  546.                     }
  547.  
  548.                     UnLock(FileLock);
  549.                 }
  550.  
  551.                 UnLock(CommandDir);
  552.             }
  553.  
  554.             if(!InitialCD)
  555.                 CurrentDir(StartCD);
  556.  
  557.             if(GotIt)
  558.             {
  559.                 CanExecute = TRUE;
  560.  
  561.                 *Error = 0;
  562.  
  563.                 Result = TRUE;
  564.             }
  565.         }
  566.     }
  567.  
  568.         // As a last resort, scan the resident program list
  569.  
  570.     if(!Result)
  571.     {
  572.         Forbid();
  573.  
  574.         if(FindSegment(Program,NULL,FALSE))
  575.         {
  576.             CanExecute = TRUE;
  577.  
  578.             *Error = 0;
  579.  
  580.             Result = TRUE;
  581.         }
  582.  
  583.         Permit();
  584.     }
  585.  
  586.         // Last check for ARexx script.
  587.  
  588.     if(!Result)
  589.     {
  590.         UBYTE RexxName[MAX_FILENAME_LENGTH];
  591.  
  592.         strcpy(RexxName,"REXX:");
  593.  
  594.         if(AddPart(RexxName,Program,MAX_FILENAME_LENGTH))
  595.         {
  596.             BPTR FileHandle;
  597.  
  598.                 // Now check if it's an ARexx script.
  599.  
  600.             if(FileHandle = Open(RexxName,MODE_OLDFILE))
  601.             {
  602.                 UBYTE    LocalBuffer[256];
  603.                 LONG    Len;
  604.  
  605.                 if((Len = Read(FileHandle,LocalBuffer,256)) > 0)
  606.                 {
  607.                     if(CanExecute = FindARexxComment(LocalBuffer,Len))
  608.                         Result = TRUE;
  609.                 }
  610.  
  611.                 Close(FileHandle);
  612.             }
  613.         }
  614.     }
  615.  
  616.         // Last check for AmigaDOS script
  617.  
  618.     if(!Result)
  619.     {
  620.         UBYTE ScriptName[MAX_FILENAME_LENGTH];
  621.  
  622.         strcpy(ScriptName,"S:");
  623.  
  624.         if(AddPart(ScriptName,Program,MAX_FILENAME_LENGTH))
  625.         {
  626.             BPTR FileLock;
  627.  
  628.             if(FileLock = Lock(ScriptName,ACCESS_READ))
  629.             {
  630.                 struct FileInfoBlock __aligned FileInfo;
  631.  
  632.                 if(Examine(FileLock,&FileInfo))
  633.                 {
  634.                     if(FileInfo . fib_DirEntryType < 0 && (FileInfo . fib_Protection & FIBF_SCRIPT) && FileInfo . fib_Size > 0)
  635.                         CanExecute = Result = TRUE;
  636.                 }
  637.  
  638.                 UnLock(FileLock);
  639.             }
  640.         }
  641.     }
  642.  
  643.     if(!CanExecute && Result)
  644.     {
  645.         *Error = ERROR_NOT_EXECUTABLE;
  646.  
  647.         Result = FALSE;
  648.     }
  649.  
  650.     ThisProcess -> pr_WindowPtr = OldPtr;
  651.  
  652.     if(Window && !Result && *Error)
  653.     {
  654.         LT_LockWindow(Parent);
  655.  
  656.         if(*Error == ERR_NOT_A_FILE)
  657.             ShowError(Parent,*Error,NULL,Program);
  658.         else
  659.             ShowError(Parent,ERR_PROGRAM_NOT_FOUND,*Error,Program);
  660.  
  661.         LT_UnlockWindow(Parent);
  662.     }
  663.  
  664.     return(Result);
  665. }
  666.  
  667.     /* FindLibDev(struct Window *Parent,STRPTR File,LONG Type,LONG *Error):
  668.      *
  669.      *    Try to locate a file.
  670.      */
  671.  
  672. BOOLEAN __regargs
  673. FindLibDev(struct Window *Parent,STRPTR File,LONG Type,LONG *Error)
  674. {
  675.     UBYTE         LocalBuffer[MAX_FILENAME_LENGTH];
  676.     STRPTR         OriginalFile;
  677.     APTR         OldPtr = ThisProcess -> pr_WindowPtr;
  678.     BPTR         FileLock;
  679.     BOOLEAN         Result        = FALSE,
  680.                  Replaced    = FALSE;
  681.     LONG         LocalError;
  682.     struct Node    *Node;
  683.  
  684.     if(!Config -> MiscConfig -> ProtectiveMode)
  685.         return(TRUE);
  686.  
  687.     if(!Error)
  688.         Error = &LocalError;
  689.  
  690.     Forbid();
  691.  
  692.     if(Type == NT_LIBRARY)
  693.         Node = FindName(&SysBase -> LibList,PathPart(File));
  694.     else
  695.         Node = FindName(&SysBase -> DeviceList,PathPart(File));
  696.  
  697.     Permit();
  698.  
  699.     if(Node)
  700.     {
  701.         *Error = 0;
  702.  
  703.         return(TRUE);
  704.     }
  705.  
  706.         // Lock out DOS requesters
  707.  
  708.     ThisProcess -> pr_WindowPtr = (APTR)-1;
  709.  
  710.         // Try to get a lock on the file
  711.  
  712. Look:
  713.  
  714.     if(FileLock = Lock(File,ACCESS_READ))
  715.     {
  716.         struct FileInfoBlock __aligned FileInfo;
  717.  
  718.             // Take a closer look
  719.  
  720.         if(Examine(FileLock,&FileInfo))
  721.         {
  722.                 // Is it actually a drawer?
  723.  
  724.             if(FileInfo . fib_DirEntryType > 0)
  725.                 *Error = ERR_NOT_A_FILE;
  726.             else
  727.             {
  728.                 if(ValidateFile(File,Type,NULL))
  729.                 {
  730.                     *Error = 0;
  731.  
  732.                     Result = TRUE;
  733.                 }
  734.                 else
  735.                     *Error = ERROR_OBJECT_WRONG_TYPE;
  736.             }
  737.         }
  738.         else
  739.             *Error = IoErr();
  740.  
  741.         UnLock(FileLock);
  742.     }
  743.     else
  744.         *Error = IoErr();
  745.  
  746.     if(!Result && !Replaced)
  747.     {
  748.         Replaced = TRUE;
  749.  
  750.         if(Type == NT_LIBRARY)
  751.             strcpy(LocalBuffer,"Libs:");
  752.         else
  753.             strcpy(LocalBuffer,"Devs:");
  754.  
  755.         OriginalFile = File;
  756.  
  757.         if(AddPart(LocalBuffer,File,MAX_FILENAME_LENGTH))
  758.         {
  759.             File = LocalBuffer;
  760.  
  761.             goto Look;
  762.         }
  763.     }
  764.  
  765.     if(Replaced)
  766.         File = OriginalFile;
  767.  
  768.     ThisProcess -> pr_WindowPtr = OldPtr;
  769.  
  770.     if(Window && !Result && *Error)
  771.     {
  772.         LT_LockWindow(Parent);
  773.  
  774.         if(*Error == ERR_NOT_A_FILE)
  775.             ShowError(Parent,*Error,NULL,File);
  776.         else
  777.             ShowError(Parent,ERR_FILE_NOT_FOUND,*Error,File);
  778.  
  779.         LT_UnlockWindow(Parent);
  780.     }
  781.  
  782.     return(Result);
  783. }
  784.